package list;

import com.google.common.base.Splitter;
import com.google.common.collect.HashMultiset;
import org.apache.commons.collections4.MultiSet;
import org.apache.commons.collections4.multiset.HashMultiSet;
import org.junit.Test;

import java.util.Arrays;

public class TestMultiSet {

    @Test
    public void test01(){
        String s = "a|b|c|a|d|c";

        Iterable<String> split = Splitter.on("|").split(s);

        HashMultiset<String> ms = HashMultiset.create();

        for (String element: split) {
            ms.add(element);
        }

        ms.elementSet().forEach(e->{
            System.out.println(e+":"+ms.count(e));
        });


    }

}
